<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tk="http://www.qdocuments.net" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="tk msxsl">
	<xsl:import href="Button.xslt"/>
	<xsl:import href="DetailItems.xslt"/>
	<xsl:variable name="tk:Toolkit" select="/Toolkit"/>
	<xsl:variable name="tk:XmlFile"/>
	<xsl:variable name="tk:AllXmlData">
		<xsl:for-each select="$tk:AllResolvers/tk:Resolver">
			<xsl:variable name="Table" select="document(tk:Xml)/Toolkit/tk:Table"/>
			<tk:Table RegName="{tk:RegName}">
				<xsl:copy-of select="$Table/@*"/>
				<xsl:copy-of select="$Table/*"/>
			</tk:Table>
		</xsl:for-each>
	</xsl:variable>
	<xsl:variable name="tk:AllXmlNodeSet" select="msxsl:node-set($tk:AllXmlData)/tk:Table"/>
	<xsl:template name="tk:Content">
		<xsl:param name="Method"/>
		<xsl:call-template name="tk:Display">
			<xsl:with-param name="Method" select="$Method"/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="tk:Field" mode="tk:Field">
		<xsl:param name="Method"/>
		<xsl:variable name="HtmlCtrl">
			<xsl:call-template name="tk:GetHtmlCtrl">
				<xsl:with-param name="Field" select="."/>
				<xsl:with-param name="Method" select="$Method"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:if test="position()!=1">,</xsl:if>
		<xsl:value-of select="tk:FieldName"/>
		<xsl:if test="$HtmlCtrl='EasySearch'">
			<xsl:text>,hd</xsl:text>
			<xsl:value-of select="tk:FieldName"/>
		</xsl:if>
	</xsl:template>
	<xsl:template name="tk:Display">
		<xsl:param name="Method"/>
		<xsl:variable name="tk:DetailResolvers" select="$tk:XmlFile/Toolkit/tk:Module/tk:Resolvers/tk:Resolver[(@Style = 'Normal') and (not(@Type) or @Type != 'View')]"/>
		<xsl:for-each select="$tk:DetailResolvers">
			<xsl:variable name="Style" select="@Style"/>
			<xsl:variable name="Tables" select="$tk:AllXmlNodeSet[@RegName=current()/tk:RegName]"/>
			<xsl:apply-templates select="$Tables" mode="tk:Display">
				<xsl:with-param name="Method" select="$Method"/>
				<xsl:with-param name="Style" select="$Style"/>
			</xsl:apply-templates>
		</xsl:for-each>
	</xsl:template>
	<xsl:template match="tk:Table" mode="tk:Display">
		<xsl:param name="Method"/>
		<xsl:param name="Style"/>
		<xsl:variable name="Data" select="$tk:Toolkit/*[local-name()=current()/@TableName]"/>
		<xsl:variable name="FieldList">
			<xsl:for-each select="tk:Field[tk:Detail]">
				<xsl:sort select="tk:Detail/@Order" data-type="number"/>
				<xsl:copy-of select="."/>
			</xsl:for-each>
		</xsl:variable>
		<xsl:variable name="FieldNodes" select="msxsl:node-set($FieldList)"/>
		<xsl:if test="@TableDesc != '' and count($tk:AllXmlNodeSet) &gt; 1">
			<tr>
				<th width="100%">
					<div align="left">
						<xsl:value-of select="@TableDesc"/>
					</div>
				</th>
				<th align="right" class="cur-hand" onclick="showContentList('{@TableName}');">
					<img src="../images/ico_listup.gif" id="imgContentList{@TableName}" border="0" align="absmiddle"/>
				</th>
			</tr>
		</xsl:if>
		<tr>
			<td colspan="2" class="td-bg" id="divContentList{@TableName}">
				<table width="100%" border="0" cellspacing="1" cellpadding="2">
					<xsl:choose>
						<xsl:when test="$Style='Normal'">
							<xsl:call-template name="tk:NormalDisplay">
								<xsl:with-param name="FieldList" select="$FieldNodes"/>
								<xsl:with-param name="Data" select="$Data"/>
								<xsl:with-param name="Method" select="$Method"/>
							</xsl:call-template>
						</xsl:when>
					</xsl:choose>
				</table>
			</td>
		</tr>
	</xsl:template>
	<xsl:template name="tk:NormalDisplay">
		<xsl:param name="FieldList"/>
		<xsl:param name="Data"/>
		<xsl:param name="Method"/>
		<xsl:for-each select="$Data">
			<xsl:apply-templates select="$FieldList/tk:Field[1]" mode="tk:DataList">
				<xsl:with-param name="DataRecord" select="."/>
				<xsl:with-param name="FieldList" select="$FieldList"/>
				<xsl:with-param name="Method" select="$Method"/>
				<xsl:with-param name="Pos" select="position()"/>
			</xsl:apply-templates>
		</xsl:for-each>
	</xsl:template>
	<xsl:template match="tk:Field" mode="tk:DataList">
		<xsl:param name="FieldList"/>
		<xsl:param name="DataRecord"/>
		<xsl:param name="Method"/>
		<xsl:param name="Pos"/>
		<xsl:variable name="HtmlCtrl">
			<xsl:call-template name="tk:GetHtmlCtrl">
				<xsl:with-param name="Field" select="."/>
				<xsl:with-param name="Method" select="$Method"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="$HtmlCtrl=''">
				<xsl:apply-templates select="following-sibling::tk:Field[1]" mode="tk:DataList">
					<xsl:with-param name="FieldList" select="$FieldList"/>
					<xsl:with-param name="DataRecord" select="$DataRecord"/>
					<xsl:with-param name="Method" select="$Method"/>
					<xsl:with-param name="Pos" select="$Pos"/>
				</xsl:apply-templates>
			</xsl:when>
			<xsl:when test="$HtmlCtrl='Hidden'">
				<xsl:apply-templates select="." mode="tk:Item">
					<xsl:with-param name="DataRecord" select="$DataRecord"/>
					<xsl:with-param name="Method" select="$Method"/>
					<xsl:with-param name="Pos" select="$Pos"/>
					<xsl:with-param name="HtmlCtrl" select="$HtmlCtrl"/>
				</xsl:apply-templates>
				<xsl:apply-templates select="following-sibling::tk:Field[1]" mode="tk:DataList">
					<xsl:with-param name="FieldList" select="$FieldList"/>
					<xsl:with-param name="DataRecord" select="$DataRecord"/>
					<xsl:with-param name="Method" select="$Method"/>
					<xsl:with-param name="Pos" select="$Pos"/>
				</xsl:apply-templates>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="NextItemName">
					<xsl:if test="tk:Display/@IsTwoColumn='true'">
						<xsl:call-template name="tk:NextItem">
							<xsl:with-param name="Field" select="following-sibling::tk:Field[1]"/>
							<xsl:with-param name="DataRecord" select="$DataRecord"/>
							<xsl:with-param name="Method" select="$Method"/>
							<xsl:with-param name="Pos" select="$Pos"/>
						</xsl:call-template>
					</xsl:if>
				</xsl:variable>
				<xsl:choose>
					<xsl:when test="$NextItemName!=''">
						<xsl:variable name="NextFieldItem" select="following-sibling::tk:Field[tk:FieldName=$NextItemName]"/>
						<xsl:apply-templates select="." mode="tk:TableRow">
							<xsl:with-param name="FieldItem" select="."/>
							<xsl:with-param name="NextFieldItem" select="$NextFieldItem"/>
							<xsl:with-param name="DataRecord" select="$DataRecord"/>
							<xsl:with-param name="Pos" select="$Pos"/>
							<xsl:with-param name="Method" select="$Method"/>
							<xsl:with-param name="HtmlCtrl" select="$HtmlCtrl"/>
						</xsl:apply-templates>
						<xsl:for-each select="$NextFieldItem">
							<xsl:apply-templates select="following-sibling::tk:Field[1]" mode="tk:DataList">
								<xsl:with-param name="FieldList" select="$FieldList"/>
								<xsl:with-param name="DataRecord" select="$DataRecord"/>
								<xsl:with-param name="Method" select="$Method"/>
								<xsl:with-param name="Pos" select="$Pos"/>
							</xsl:apply-templates>
						</xsl:for-each>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates select="." mode="tk:TableRow">
							<xsl:with-param name="FieldItem" select="."/>
							<xsl:with-param name="DataRecord" select="$DataRecord"/>
							<xsl:with-param name="Pos" select="$Pos"/>
							<xsl:with-param name="Method" select="$Method"/>
							<xsl:with-param name="HtmlCtrl" select="$HtmlCtrl"/>
						</xsl:apply-templates>
						<xsl:apply-templates select="following-sibling::tk:Field[1]" mode="tk:DataList">
							<xsl:with-param name="FieldList" select="$FieldList"/>
							<xsl:with-param name="DataRecord" select="$DataRecord"/>
							<xsl:with-param name="Method" select="$Method"/>
							<xsl:with-param name="Pos" select="$Pos"/>
						</xsl:apply-templates>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="tk:NextItem">
		<xsl:param name="Field"/>
		<xsl:param name="DataRecord"/>
		<xsl:param name="Method"/>
		<xsl:param name="Pos"/>
		<xsl:for-each select="$Field">
			<xsl:variable name="HtmlCtrl">
				<xsl:call-template name="tk:GetHtmlCtrl">
					<xsl:with-param name="Field" select="."/>
					<xsl:with-param name="Method" select="$Method"/>
				</xsl:call-template>
			</xsl:variable>
			<xsl:choose>
				<xsl:when test="$HtmlCtrl = ''">
					<xsl:call-template name="tk:NextItem">
						<xsl:with-param name="Field" select="following-sibling::tk:Field[1]"/>
						<xsl:with-param name="DataRecord" select="$DataRecord"/>
						<xsl:with-param name="Method" select="$Method"/>
						<xsl:with-param name="Pos" select="$Pos"/>
					</xsl:call-template>
				</xsl:when>
				<xsl:when test="$HtmlCtrl ='Hidden'">
					<xsl:apply-templates select="." mode="tk:Item">
						<xsl:with-param name="DataRecord" select="$DataRecord"/>
						<xsl:with-param name="Method" select="$Method"/>
						<xsl:with-param name="Pos" select="$Pos"/>
						<xsl:with-param name="HtmlCtrl" select="$HtmlCtrl"/>
					</xsl:apply-templates>
					<xsl:call-template name="tk:NextItem">
						<xsl:with-param name="Field" select="following-sibling::tk:Field[1]"/>
						<xsl:with-param name="DataRecord" select="$DataRecord"/>
						<xsl:with-param name="Method" select="$Method"/>
						<xsl:with-param name="Pos" select="$Pos"/>
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:if test="tk:Display/@IsTwoColumn='true'">
						<xsl:value-of select="tk:FieldName"/>
					</xsl:if>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tk:GetHtmlCtrl">
		<xsl:param name="Field"/>
		<xsl:param name="Method"/>
		<xsl:value-of select="$Field/tk:Detail/@HtmlCtrl"/>
	</xsl:template>
	<xsl:template match="tk:Field" mode="tk:TableRow" name="tk:TableRow">
		<xsl:param name="FieldItem"/>
		<xsl:param name="NextFieldItem"/>
		<xsl:param name="DataRecord"/>
		<xsl:param name="Method"/>
		<xsl:param name="Pos"/>
		<xsl:param name="HtmlCtrl"/>
		<tr>
			<xsl:apply-templates select="." mode="tk:Item">
				<xsl:with-param name="DataRecord" select="$DataRecord"/>
				<xsl:with-param name="Method" select="$Method"/>
				<xsl:with-param name="Pos" select="$Pos"/>
				<xsl:with-param name="HtmlCtrl" select="$HtmlCtrl"/>
			</xsl:apply-templates>
			<xsl:if test="$NextFieldItem">
				<xsl:for-each select="$NextFieldItem">
					<xsl:variable name="NextHtmlCtrl">
						<xsl:call-template name="tk:GetHtmlCtrl">
							<xsl:with-param name="Field" select="."/>
							<xsl:with-param name="Method" select="$Method"/>
						</xsl:call-template>
					</xsl:variable>
					<xsl:apply-templates select="." mode="tk:Item">
						<xsl:with-param name="DataRecord" select="$DataRecord"/>
						<xsl:with-param name="Method" select="$Method"/>
						<xsl:with-param name="Pos" select="$Pos"/>
						<xsl:with-param name="HtmlCtrl" select="$NextHtmlCtrl"/>
					</xsl:apply-templates>
				</xsl:for-each>
			</xsl:if>
		</tr>
	</xsl:template>
	<xsl:template match="tk:Field" mode="tk:Item">
		<xsl:param name="DataRecord"/>
		<xsl:param name="Method"/>
		<xsl:param name="Pos"/>
		<xsl:param name="HtmlCtrl"/>
		<xsl:variable name="Value" select="$DataRecord/*[local-name()=current()/tk:FieldName]"/>
		<xsl:choose>
      <xsl:when test="$HtmlCtrl='DetailUpload'">
        <xsl:call-template name="tk:DetailUpload">
          <xsl:with-param name="Field" select="."/>
          <xsl:with-param name="DataRecord" select="$DataRecord"/>
        </xsl:call-template>
      </xsl:when>
			<xsl:when test="$HtmlCtrl='Hidden'">
				<xsl:call-template name="tk:Hidden">
					<xsl:with-param name="Field" select="."/>
					<xsl:with-param name="Value" select="$Value"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$HtmlCtrl='Detail'">
				<xsl:call-template name="tk:Detail">
					<xsl:with-param name="Field" select="."/>
					<xsl:with-param name="Value" select="$Value"/>
				</xsl:call-template>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
